﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QLCHBANGIAY.DATA
{
    public class Product
    {

        #region[Declare variables]
        private string _Id;
        private string _Name;
        private string _Content;
        private string _Price;
        private string _Image;
        private string _Categoryid;
        private string _Keyword;
        private string _Active;
        private string _Image1;
        private string _Image2;
        private string _Count;
        private string _DateBegin;
        private string _DateEnd;
        //them bien counter dể đếm số lượng sản phẩm
        private int counter;
        public int getCounter()
        {
            return counter;
        }
        public void setCounter(int counter)
        {
            this.counter = counter;
        }
        #endregion
        #region[Public Properties]
        public string Id { get { return _Id; } set { _Id = value; } }
        public string Name { get { return _Name; } set { _Name = value; } }
        public string Content { get { return _Content; } set { _Content = value; } }
        public string Price { get { return _Price; } set { _Price = value; } }
        public string Image { get { return _Image; } set { _Image = value; } }
        public string Categoryid { get { return _Categoryid; } set { _Categoryid = value; } }
        public string Keyword { get { return _Keyword; } set { _Keyword = value; } }
        public string Active { get { return _Active; } set { _Active = value; } }
        public string Image1 { get { return _Image1; } set { _Image1 = value; } }
        public string Image2 { get { return _Image2; } set { _Image2 = value; } }
        public string Count { get { return _Count; } set { _Count = value; } }
        public string DateBegin { get { return _DateBegin; } set { _DateBegin = value; } }
        public string DateEnd { get { return _DateEnd; } set { _DateEnd = value; } }
        #endregion
        #region[Product IDataReader]
        public Product ProductIDataReader(IDataReader dr)
        {
            Product obj = new Product();
            obj.Id = (dr["Id"] is DBNull) ? string.Empty : dr["Id"].ToString();
            obj.Name = (dr["Name"] is DBNull) ? string.Empty : dr["Name"].ToString();
            obj.Content = (dr["Content"] is DBNull) ? string.Empty : dr["Content"].ToString();
            obj.Price = (dr["Price"] is DBNull) ? string.Empty : dr["Price"].ToString();
            obj.Image = (dr["Image"] is DBNull) ? string.Empty : dr["Image"].ToString();
            obj.Categoryid = (dr["Categoryid"] is DBNull) ? string.Empty : dr["Categoryid"].ToString();
            obj.Keyword = (dr["Keyword"] is DBNull) ? string.Empty : dr["Keyword"].ToString();
            obj.Active = (dr["Active"] is DBNull) ? string.Empty : dr["Active"].ToString();
            obj.Image1 = (dr["Image1"] is DBNull) ? string.Empty : dr["Image1"].ToString();
            obj.Image2 = (dr["Image2"] is DBNull) ? string.Empty : dr["Image2"].ToString();
            obj.Count = (dr["Count"] is DBNull) ? string.Empty : dr["Count"].ToString();
            obj.DateBegin = (dr["DateBegin"] is DBNull) ? string.Empty : dr["DateBegin"].ToString();
            obj.DateEnd = (dr["DateEnd"] is DBNull) ? string.Empty : dr["DateEnd"].ToString();
            return obj;
        }
        #endregion

        public bool equals(Object obj)
        {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            //if (getClass() != obj.getClass())
            //    return false;
            Product other = (Product)obj;
            if (Id != other.Id)
                return false;
            return true;
        }
    }
}
